<template>
    <div>
        <a-modal
            v-model:visible="visible"
            id="onSiteInspectionCheckInId"
            width="100%"
            wrapClassName="full-modal-material-review"
            :maskClosable="false"
            :forceRender="true"
            @cancel="cancelChange"
        >
            <template slot="title">
                 <!-- <div> -->
                    <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" >
                        {{ currentData.fsxmc }}
                        <span>{{ currentData.fqymc }}</span>
                        <span
                        v-if="currentData.fslbh" 
                        style="display: inline-block;border:2px solid #4eef66;border-radius: 17.3px;color: #4eef66;margin-left: 10px;font-size: 14px;"
                        >{{ currentData.fslbh }}</span>
                    </span>
                 <!-- </div> -->
            </template>
            <a-spin size="large" :spinning="spinning" :key="spinningKey">
                <!-- <div class="top-handle-v">
                    <div style="display: flex;align-items: center;">
                        <div>
                            <a-button class="blue-btn" type="primary" v-if="currentData.isZZState && $refs.sceneInspectRef && $refs.sceneInspectRef.currentSteps == 0" style="margin-left: 10px;" @click="taskAllocationClick()" icon="apartment">{{currentData.isRwfpFlag?'技术审评任务分配':'重新分配审评任务'}}</a-button>
                            <a-button class="orange-btn" style="margin-left: 10px;" @click="searchBasisClick()" icon="profile" type="primary">查阅法规</a-button>
                            <a-button class="ant-btn-background-ghost" style="margin-left: 10px;" @click="inspectionPlanMaterialsClick()" icon="profile" type="dashed">审评方案材料</a-button>
                            <a-button v-if="false" style="margin-left: 10px;" @click="rectificationClick('pushQyBcZgNotice')" icon="profile">发起整改</a-button>
                            <a-button v-if="false" style="margin-left: 10px;" @click="historyListClick('querySqsxBczgjlHistoryList')" icon="clock-circle">整改历史记录</a-button>
                            <a-button v-if="(currentData.isZZState && $refs.sceneInspectRef && $refs.sceneInspectRef.currentSteps == 3)" style="margin-left: 10px;" class="blue-btn" type="primary" @click="linkHandling('spcysubmitFlow')" icon="edit">结束技术审评</a-button>
                            <a-button style="margin-left: 15px;" class="blue-btn" type="primary" @click="linkHandlingTwo('spcysubmitFlow')">提交到综合评定</a-button>
                            <a-button v-if="!bxsqBtn" style="margin-left: 10px;" class="blue-btn" type="primary" @click="reimburseClick(currentData)">申请报销</a-button>
                            <a-button v-if="currentData.isZZState" style="margin-left: 10px;" icon="rollback" @click="returnPreviousLink('spcyreturnUpperFlowJob')">退回</a-button>
                            <a-button v-if="false" style="margin-left: 10px;" class="blue-btn" type="primary" icon="interaction" @click="internalTransferClick('spcytransferFlowJob')">内部转办</a-button>
                        </div>
                        <div style="margin-left: 50px;">
                            <a-button class="blue-btn" type="primary" @click="refreshClick()" icon="reload">刷新</a-button>
                        </div>
                    </div>
                </div> -->
                <!-- <div style="height: 53px;"></div> -->
                <div style="width: 100%;display: flex;">
                    <!-- <div style="height: calc(100vh - 70px);width: 140px;background-color: #fff;padding: 10px;">
                        <commpStep :parameterData="{index:5}"></commpStep>
                    </div> -->
                    <!-- style="width: calc(100% - 150px);margin-left: 10px;" -->
                    <div style="width: 100%;" v-if="sceneInspectShow">
                        <sceneInspect
                         ref="sceneInspectRef" 
                         @reviseClick="reviseClick" 
                         @linkHandling="linkHandling" 
                         @taskAllocationClick="taskAllocationClick" 
                         @searchBasisClick="searchBasisClick"
                         @refreshClick="refreshClick"
                         @inspectionPlanMaterialsClick="inspectionPlanMaterialsClick"
                         @reimburseClick="reimburseClick"
                         :key="sceneInspectKey"/>
                    </div>
                    
                </div>
            </a-spin>
            <processingConditionsAll ref="processingConditionsAllRef" :processingData="processingData" @interfaceSuccessful="interfaceSuccessful"></processingConditionsAll><!--原来共用-->
            <processingConditionsOnSiteInspection ref="processingConditionsOnSiteInspectionRef" :processingData="processingData" @interfaceSuccessful="interfaceSuccessful"/>
            <assignPersonnel ref="assignPersonnelRef" />
            <supplementaryRectification ref="supplementaryRectificationRef" @rectificationSuccess="rectificationSuccess"/>
            <supplementaryHistory ref="supplementaryHistoryRef"/>
            <newLawEditLawsAndRegulationsViewFile ref="newLawEditLawsAndRegulationsViewFileRef"/>
            <huHandleModal ref="huHandleModalRef" @success="huHandleSuccess"></huHandleModal><!-- 日常考评/日常考评互评 -->
            <handleModal ref="handleModalRef" @success="huHandleSuccess"></handleModal><!-- 日常考评/其他环节 -->
            <!-- 见习考评、、暂时先用、还未改版 -->
            <prepareinspectormIncrease ref="prepareinspectormIncreaseRef" @handlerSave="huHandleSuccess" />
            <reimbursementModel ref="reimbursementModelRef" />
        </a-modal>
    </div>
</template>
<script>
import sceneInspect from './sceneInspect.vue'
import assignPersonnel from './assignPersonnel.vue'
import newLawEditLawsAndRegulationsViewFile from '../../../../newLaw/editLawsAndRegulations/viewFile.vue'
import huHandleModal from '../../../../dailyEvaluation/huHandleModal.vue'
import handleModal from '../../../../dailyEvaluation/handleModal.vue'
import { spcyMyInfokpdbList, nkJcybxgetLczt} from './service/index'
import prepareinspectormIncrease from '../../../../everydayCheck/prepareinspectorm/increase.vue'
import reimbursementModel from '../../../../n-1-inspectorManage/expenseReimbursement/reimbursementModel.vue'
import processingConditionsOnSiteInspection from '@/components/processing-conditions/processing-conditions-OnSiteInspection.vue'
export default {
    components:{
        sceneInspect,
        assignPersonnel,
        newLawEditLawsAndRegulationsViewFile,
        huHandleModal,
        handleModal,
        prepareinspectormIncrease,
        reimbursementModel,
        processingConditionsOnSiteInspection,
    },
    props:{

    },
    data(){
        return{
            visible:false,
            spinning:false,
            processingData:{},
            currentData:{},
            spinningKey:null,
            jxkpJobList:[],
            rckpJobList:[],
            currentSteps:0,
            fullscreen:false,
            bxsqBtn:true,
            sceneInspectKey:null,
            sceneInspectShow:false,
            screenInnerHeight:0,
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getData(row){
            //console.log('技术审评我拿到7什么',row.fullscreen)
            this.screenInnerHeight = window.innerHeight
            //是否显示申请报销
            nkJcybxgetLczt({sqsxid:row.sqsxid}).then(res=>{
                if(res.code == 200){
                    this.bxsqBtn = res.result
                }else{
                    this.bxsqBtn = true
                }
            })
            this.fullscreen = row.fullscreen?true:false
            //console.log('我拿到了什么状态',this.currentSteps)
            this.cancelLoading()
            this.currentData = row
            this.screen(row)
            
            this.getPendingEvaluation()
            
        },
        screen(row) {
            let element = document.documentElement;
            if (this.fullscreen) {
                this.sceneInspectShow = true
                this.$nextTick(()=>{
                    setTimeout(()=>{
                        this.$refs.sceneInspectRef.getData({...row,currentRefreshSteps:this.currentSteps,screenInnerHeight:this.screenInnerHeight})
                        // this.sceneInspectKey = Date.now()
                    },200)
                    
                })
            } else {
                // 全屏
                if (element.requestFullscreen) {
                    element.requestFullscreen();
                } else if (element.webkitRequestFullScreen) {
                    element.webkitRequestFullScreen();
                } else if (element.mozRequestFullScreen) {
                    element.mozRequestFullScreen();
                } else if (element.msRequestFullscreen) {
                    // IE11
                    element.msRequestFullscreen();
                }
                this.sceneInspectShow = true
                
                this.$nextTick(()=>{
                    setTimeout(()=>{
                        this.$refs.sceneInspectRef.getData({...row,currentRefreshSteps:this.currentSteps,screenInnerHeight:this.screenInnerHeight})
                        // this.sceneInspectKey = Date.now()
                    },200)
                    
                })
            }
            
            
        },
        reimburseClick(row){
            this.$refs.reimbursementModelRef.getData({sqsxid:row.sqsxid,view:false,heightType:'model'})
            this.$refs.reimbursementModelRef.visible = true
        },
        cancelChange(){
            //console.log('我关闭了')
            // this.fullscreen = true
            //console.log('我在关闭检测',document.fullscreenElement)
            if(document.fullscreenElement){
                if (document.exitFullscreen) {
                    document.exitFullscreen();
                } else if (document.webkitCancelFullScreen) {
                    document.webkitCancelFullScreen();
                } else if (document.mozCancelFullScreen) {
                    document.mozCancelFullScreen();
                } else if (document.msExitFullscreen) {
                    document.msExitFullscreen();
                }
            }
            
        },
        getPendingEvaluation(){
            spcyMyInfokpdbList({sqsxid:this.currentData.sqsxid}).then(res=>{
                if(res.code == 200){
                    //console.log(res)
                    this.jxkpJobList = res.result.jxkpJobList
                    this.rckpJobList = res.result.rckpJobList
                }else{
                    this.jxkpJobList = []
                    this.rckpJobList = []
                }
            })
        },
        returnClick(){//返回
            this.visible = false
        },
        reviseClick(val){
            this.$emit('reviseClick',val)
        },
        refreshClick(){//刷新
            if(this.$refs.sceneInspectRef && this.$refs.sceneInspectRef.currentSteps){
                this.currentSteps = this.$refs.sceneInspectRef.currentSteps
            }
            //console.log('我拿到了什么状态1',this.currentSteps)
            this.$emit('reviseClick',{...this.currentData,noFirstLoad:false,fullscreen:document.fullscreenElement?false:true})
            // this.spinning = true
            // this.spinningKey = Date.now()
            this.cancelLoading()
        },
        //任务分配
        taskAllocationClick(row){
            this.$refs.assignPersonnelRef.visible = true
            this.$refs.assignPersonnelRef.getData(this.currentData,row,this.currentData.fhbsxzt)
        },
        cancelLoading(){
            let timer = setInterval((val)=>{
                this.spinning = false
                clearInterval(timer);
            },500)
            
        },
        successReturn(val){
            this.visible = val
            this.$emit('successReturn')
        },
        //提交
        linkHandling(val){
            this.$refs.processingConditionsOnSiteInspectionRef.processingConditionsVisible = true
            let data = {
                interface:val,
                sqsxid:this.currentData.sqsxid,
                nextNodeDbrList:this.currentData.nextNodeDbrList,
                nextNode:this.currentData.nextNode,
                jobid:this.currentData.jobid,
                headerLeftTitle:'提交',
                headerCenterTitle:'药品生产查验--技术审评',
                otherData:{
                    // fscms:'技术审评',
                },
                isBlr:false,
                isNew:true,
            }
            this.processingData = data
            this.$refs.processingConditionsOnSiteInspectionRef.getData(data)
        },
        //提交到综合评定
        linkHandlingTwo(val){
            //  
            // let result = this.$refs.planProductionRef.sceneSubmitClick('技术审评')
            // if(result){
                this.$refs.processingConditionsAllRef.processingConditionsVisible = true
                let data = {
                    interface:val,
                    sqsxid:this.currentData.sqsxid,
                    nextNodeDbrList:this.currentData.nextNodeDbrList,
                    nextNode:'综合评定',
                    jobid:this.currentData.jobid,
                    headerLeftTitle:'提交到综合评定',
                    headerCenterTitle:'药品生产查验--技术审评',
                    isBlr:false,
                    otherData:{
                        // fscms:'技术审评',
                        nextNode:'综合评定',
                    },
                    isNew:true,
                }
                this.processingData = data
                this.$refs.processingConditionsAllRef.getData(data)
            // }

        },
        //退回
        returnPreviousLink(val){
            this.$refs.processingConditionsAllRef.processingConditionsVisible = true
            let data = {
                interface:val,
                sqsxid:this.currentData.sqsxid,
                nextNodeDbrList:this.currentData.nextNodeDbrList,
                nextNode:this.currentData.nextNode,
                jobid:this.currentData.jobid,
                isBlr:false,
                isThhj:true,
                isXyb:false,
                headerLeftTitle:'退回',
                headerCenterTitle:'药品生产查验--材料审查',
                isNew:true,
                NoViewBlr:true,
            }
            this.processingData = data
            this.$refs.processingConditionsAllRef.getData(data)
        },
        //内部转办
        internalTransferClick(val){
            this.$refs.processingConditionsAllRef.processingConditionsVisible = true
            let data = {
                interface:val,
                sqsxid:this.currentData.sqsxid,
                jobid:this.currentData.jobid,
                isBlyj:true,
                isZbxx:false,
                isXyb:false,
                isNbbl:true,
                isBlr:false,
                NoViewBlr:true,
                headerLeftTitle:'内部转办',
                headerCenterTitle:'药品生产查验--'+(this.currentData.fhjmc  == '现场检查'?'技术审查': this.currentData.fhjmc),
            }
            this.processingData = data
            this.$refs.processingConditionsAllRef.getData(data)
        },
        inspectionPlanMaterialsClick(){
            this.$refs.sceneInspectRef.planMaterialsvisible = true
            this.$refs.sceneInspectRef.tabPaneChange('审评方案拟定')
            
        },
        searchBasisClick(){//查阅依据
            this.$refs.newLawEditLawsAndRegulationsViewFileRef.getData('',this.$refs.sceneInspectRef && this.$refs.sceneInspectRef.selectReportItem && this.$refs.sceneInspectRef.selectReportItem.sqsxid?this.$refs.sceneInspectRef.selectReportItem.sqsxid:this.currentData.sqsxid)
            this.$refs.newLawEditLawsAndRegulationsViewFileRef.viewFileVisible = true
        },
        pendingEvaluationClick(){
            if(this.jxkpJobList.length  || this.rckpJobList.length){
                const $pulldown = this.$refs.pulldownRef
                if ($pulldown) {
                    $pulldown.togglePanel()
                }
            }else{
                this.$message.warning('暂无需评价')
            }
            
        },
        assessment(val,row){
            if(val == '日常考评'){
                let data = {
                    jobid:row.id,
                    fhjmc:row.fhjmc == '现场检查'?'技术审查':row.fhjmc,
                    sqsxid:this.currentData.sqsxid,
                }
                if(row.fhjmc == '检查员互评'){
                    this.$refs.huHandleModalRef.getData(data,false)
                    this.$refs.huHandleModalRef.huHandleModalVisible = true
                }
                if(row.fhjmc == '经办人审核'){
                    this.$refs.handleModalRef.getData(data,true,false)
                    this.$refs.handleModalRef.handleModalVisible = true
                }
                if(row.fhjmc == '科室复核'){
                    this.$refs.handleModalRef.getData(data,true,true)
                    this.$refs.handleModalRef.handleModalVisible = true
                    this.$refs.handleModalRef.isBlyj = true
                }
            }else{
                //console.log(row)
                this.$refs.prepareinspectormIncreaseRef.getData({...row,ybid:'',jobid:row.id})
            }
        },
        huHandleSuccess(){
            this.getPendingEvaluation()
        },
        rectificationClick(val){
            this.$refs.supplementaryRectificationRef.visible = true
            this.$refs.supplementaryRectificationRef.getData(
                {interfaceValue:val,modalTitle:'企业整改',
                isTextMessage:true,fsqsxid:this.currentData.sqsxid,isTime:true,jobid:this.currentData.jobid},
                {opinion:'fzgyj',timeLimit:'fzgsx'}
            )
        },
        historyListClick(val){
            this.$refs.supplementaryHistoryRef.visible = true
            this.$refs.supplementaryHistoryRef.getData({interfaceValue:val,modalTitle:'企业整改历史',sqsxid:this.currentData.sqsxid})
        },
        rectificationSuccess(){

        },
        //提交成功后
        interfaceSuccessful(){
            this.successReturn(false)
        },
    }
}
</script>
<style lang="less">
.full-modal-material-review {
    .ant-modal-title{
        
    }
  .ant-modal {
    max-width: 100%;
    top: 0;
    padding-bottom: 0;
    margin: 0;
    height: calc(100vh);
    overflow-y: auto;
  }
  .ant-modal-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh);
    // background: #fff;
  }
  .ant-modal-body {
    flex: 1;
    background: #f4f7fc !important;
    padding: 0px;
    height: calc(100vh - 50px);
  }
  .ant-modal-footer{
    display: none;
  }
  .pending-evaluation-item{
    border-bottom: 1px solid #d9d9d9;
    display: flex;
    align-items: center;
    padding: 5px;
    .text-box{
        color: #5ca3e5;
        font-weight: 600;
        font-size: 16px;
        flex: 1;
    }
  }
}
</style>